﻿<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../Scripts/jquery.min.js"></script>
</head>

<body>

    <input type="file" id="files" name="files" multiple="multiple" />
    <input type="button" id="upload" value="Upload Selected Files" />

    <script type="text/javascript">


        $("#upload").click(function (evt) {
            var fileUpload = $("#files").get(0);
            var files = fileUpload.files;
            var data = new FormData();
            //data.age=10;
            console.log("length=" + files.length);
            for (var i = 0; i < files.length; i++) {
                data.append(files[i].name, files[i]);
            }
            $.ajax({
                type: "POST",
                url: "http://localhost:5000/api/UploadFile/UploadFile?userid=100",
                contentType: false,
                processData: false,
                data: data,
                success: function (data) {
                    alert(data.result);
                },
                error: function (data) {
                    debugger;
                    alert(data);
                }
            });
        });

    </script>
</body>

</html>